package cn.yh.register.client;

public class Test {
    public static void main(String[] args) {
        Test test = new Test();
        test.test2();
    }
    void test2(){
        int arr [] = {1, 8, 9, 5,4,3};

        for (int i = 0; i < arr.length - 1; i++) {
            int index = i;
            for (int j = i+1; j < arr.length; j++) {
                if (arr[index]>arr[j]){
                    index = j;
                }
            }
            int temp = arr[i];
            arr[i] = arr[index];
            arr[index] = temp;
        }
        for (int i = 0; i < arr.length; i++) {

            System.out.print(arr[i]+"、");
        }
    }


    void test1(){
        int arr [] = {1, 8, 9, 5,4,3};
        int temp = 0;

        for (int i = 0; i < arr.length-1; i++) {
            for (int j = 0; j < arr.length-i-1; j++) {
                if (arr[j]>arr[j+1]) {
                    temp=arr[j];
                    arr[j]=arr[j+1];
                    arr[j+1] = temp;
                }
            }
        }

        for (int i = 0; i < arr.length; i++) {

            System.out.print(arr[i]+"、");
        }
    }
}
